package com.healthfitness.floating.ui.compose

import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay

@Composable
fun FloatingContent() {

    var time by remember { mutableStateOf(1) }
    // 启动一个协程，每秒更新一次 time
    LaunchedEffect(Unit) {
        while (true) {
            delay(1000L) // 每隔 1 秒
            time++       // 自增
            Log.d("linlian ","upate time $time")
        }
    }


    Column(
        modifier = Modifier
            .background(Color(0xAAFFFFFF)) // 半透明背景
            .padding(16.dp)
            .size(200.dp)
            .wrapContentHeight()
    ) {
        Button(onClick = { /* 点击逻辑1 */ }, modifier = Modifier.fillMaxWidth()) {
            Text("按钮$time")
        }

    }
}